import { FC } from 'react';
import { Layout, Space, Typography } from 'antd';

import styles from '../index.less';
import { history } from 'umi';

const username = localStorage.getItem('username');
const Index: FC = () => {
  const exit = () => {
    localStorage.clear();
    history.push('/login');
  };

  return (
    <Layout.Header
      className={styles.siteLayoutBackground}
      style={{
        padding: '0 16px',
        borderBottom: '1px solid #1890ff',
        textAlign: 'right',
      }}
    >
      <Space size="middle">
        <Typography.Text>欢迎你,{username}</Typography.Text>
        <Typography.Link onClick={exit}>退出</Typography.Link>
      </Space>
    </Layout.Header>
  );
};

export default Index;
